<?php
	include_once("king_head.php");
?>
<?php
	include_once("ClsSebent/config.php");

	if ($page_id == "")
	{?>
		<TABLE width="100%">
<TR width="100%" align="center">
	<TD nowrap >
	 Please select a Page to manage Meta-tag. <form><input type=hidden name=site_id value="<?php echo $_SESSION['SITE_ID']; ?>"><select name=page_id><?php	showPageOption($_SESSION['SITE_ID'],"$page_id");?>
	 </select><input type=submit value=Go></form>
	</TD>
</TR>
</TABLE>
<?php 
include_once("king_foot.php");
exit;
}//if
else 
{
	if("$action"=="Save" && $_SESSION['SITE_ID'] != "")
	{
		if($updates=='') $page_updates='N';
				$sql="UPDATE site_page SET meta_keywords='$meta_keywords',meta_description='$meta_description', meta_title='$meta_title', u_pagemeta='$updates' WHERE id='$page_id'";
				//echo $sql;
		mysql_query($sql);

			//******************Global Page Meta Tags changed.
			$qry="Select site_id from reseller where updates='Y'";
			$res=mysql_query($qry);
			$qry1="Select page_title from site_page where id=".$page_id;
			//echo $qry1;
			$res1=mysql_query($qry1);
			$P=mysql_fetch_array($res1);
			$pTitle=mysql_escape_string($P["page_title"]);
			//echo $pTitle;
			if($_SESSION['SITE_ID']==101)
			{
			while($rowx=mysql_fetch_row($res))
			{
			$sid=$rowx[0];
			$uq="Select u_pagemeta from site_page where site_id=$sid and page_title='$pTitle'";
			$ur=mysql_query($uq);
			$urw=mysql_fetch_array($ur);
			if(($urw['u_pagemeta']=='Y') && ($sid!=0))
			{
				$qry="UPDATE site_page SET meta_keywords='$meta_keywords',meta_description='$meta_description', meta_title='$meta_title' WHERE site_id=$sid AND page_title='$pTitle'";
				
				//echo $qry."\n";
				mysql_query($qry);	
						
			}//if
			}//while
			}//if
			//**********************
	echo "<H4><FONT COLOR=red>Page Meta Tags Updated Successfully!</font></H4><BR>";
	}//if
}//else
	$sql="SELECT * FROM site_page WHERE id=$page_id";
//echo $sql;
	$result = mysql_query($sql);
	if($row=mysql_fetch_array($result))
	{
		$meta_keywords=$row["meta_keywords"];
		$meta_description=$row["meta_description"];
		$meta_title=$row["meta_title"];	
		//echo $row["u_pagemeta"];	
	}//if
?>
<CENTER>
<TABLE width="100%">
<TR width="100%">
	<TD nowrap align=right>
	<form><input type=hidden name=site_id value="<?php echo $_SESSION['SITE_ID']; ?>"><select name=page_id><?php showPageOption($_SESSION['SITE_ID'],"$page_id");
	?></select><input type=submit value=Go></form>
	</TD>
</TR>
</TABLE>
<H2> Manage Meta-Tag for a Page</H2>
<form enctype="multipart/form-data"  method="post"><input type=hidden name=site_id value="<?php echo $_SESSION['SITE_ID']; ?>">
<TABLE>
<tr><td>Meta title </td><td><input name=meta_title value="<?php echo $meta_title; ?>" size=100 maxlength=100></td></tr>
<tr><td>Meta Description </td><td><textarea name=meta_description rows=5 cols=80><?php echo $meta_description; ?></textarea></td></tr>
<tr><td>Meta Keyword <BR><FONT SIZE=1>(Keyword should<BR>be saprated<BR>by ",")</FONT></td><td><textarea name=meta_keywords rows=5 cols=80><?php echo $meta_keywords; ?></textarea></td></tr>
<TR><td height="38" width="88">Updates</td><td height="38" colspan="2"><input type="checkbox" name=updates <?php if($row['u_pagemeta']=='Y')echo"checked";?> value="Y" size=20>&nbsp;</td></tr>
<td colspan=2 align=center><input type=submit name=action value=Save></TD>
</TR>
</TABLE></form>
</CENTER>
<?php
	include_once("king_foot.php");
?>